home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 334_03 / x11.trm < prev   
Text File  |  1991-02-04  |  2KB  |  78 lines

  1. /*
  2.  *    x11.trm  --- inboard terminal driver for X11
  3.  */
  4.  
  5. #define X11_XMAX 4096
  6. #define X11_YMAX 4096
  7.  
  8. /* approximations for typical font/screen sizes */
  9. #define X11_VCHAR (X11_YMAX/25) 
  10. #define X11_HCHAR (X11_XMAX/100) 
  11. #define X11_VTIC (X11_YMAX/100)
  12. #define X11_HTIC (X11_XMAX/150)
  13.  
  14. #define X11_nopts 22
  15. char X11_opts[X11_nopts][20] = {
  16.    "-iconic", "-rv", "-reverse", "+rv", "-synchronous", 
  17.    "-display", "-geometry", "-bg", "-background", "-bd", "-bordercolor", "-bw",
  18.    "-borderwidth", "-fg", "-foreground", "-fn", "-font", "-name", 
  19.    "-selectionTimeout", "-title", "-xnllanguage", "-xrm" 
  20.    };
  21. int X11_optarg[X11_nopts] = { 
  22.    0, 0, 0, 0, 0,
  23.    1, 1, 1, 1, 1, 1, 1,
  24.    1, 1, 1, 1, 1, 1, 
  25.    1, 1, 1, 1
  26.    };
  27.  
  28. FILE *X11_pipe, *popen();
  29. char X11_command[1024]= "gnuplot_x11 -name gnuplot";
  30.  
  31.  
  32. /*   X11_args - scan gnuplot command line for standard X Toolkit options */
  33.  
  34. X11_args(argc, argv) int argc; char *argv[]; {
  35.    int nx11 = 0, n;
  36.  
  37.    while(++argv, --argc > 0) {
  38.       for (n=0; n<X11_nopts; n++) {
  39.      if (!strcmp(*argv, X11_opts[n])) {
  40.         strcat(X11_command, " ");
  41.         strcat(X11_command, *argv); 
  42.         if (X11_optarg[n]) {
  43.            if (--argc <= 0) return(nx11);
  44.            strcat(X11_command, " \"");
  45.            strcat(X11_command, *++argv); 
  46.            strcat(X11_command, "\"");
  47.            nx11++;
  48.            }
  49.         nx11++; break;
  50.         }
  51.      }
  52.       if (n == X11_nopts) break; 
  53.       }
  54.    return(nx11);
  55.    }
  56.  
  57. X11_init() { X11_pipe = popen(X11_command, "w"); }
  58.  
  59. X11_reset() { fprintf(X11_pipe, "R\n"); fflush(X11_pipe); }
  60.  
  61. X11_text() { fprintf(X11_pipe, "E\n"); fflush(X11_pipe); }
  62.  
  63. X11_graphics() { fprintf(X11_pipe, "G\n"); }
  64.  
  65. X11_move(x,y) unsigned int x,y; { fprintf(X11_pipe, "M%04d%04d\n", x, y); }
  66.  
  67. X11_vector(x,y) unsigned int x,y; { fprintf(X11_pipe, "V%04d%04d\n", x, y); }
  68.  
  69. X11_linetype(lt) int lt; { fprintf(X11_pipe, "L%04d\n", lt); }
  70.  
  71. X11_put_text(x,y,str) unsigned int x,y; char str[]; {
  72.    fprintf(X11_pipe, "T%04d%04d%s\n", x, y, str);
  73.    }
  74. X11_justify_text(mode) enum JUSTIFY mode; {
  75.    fprintf(X11_pipe, "J%04d\n", mode);
  76.    return(TRUE);
  77.    }
  78.